﻿
Namespace LightSwitchApplication

    Public Class Animal

        Private Sub xArchived_Compute(ByRef result As Integer)
            ' Set result to the desired field value
            'Dim move As Movement = Nothing
            'If Me.Movements.Count > 0 Then
            'move = Me.Movements.OrderByDescending(Function(a) a.MovementDate).FirstOrDefault()
            'result = move.MovementType.Id
            'Else
            'result = 0
            'End If

        End Sub

        Private Sub DaysSinceArrival_Compute(ByRef result As Integer)
            ' Set result to the desired field value
            If DateBroughtIn IsNot Nothing Then
                result = GetDays(DateBroughtIn)
            End If
        End Sub

        Private Function GetDays(ByVal mydate As Date) As Integer
            Dim difference As TimeSpan = Date.Now - mydate
            Return difference.Days
        End Function
    End Class

End Namespace
